class ScrawlFile {
  String thumb;
  LineInfo lines;
  StrokeInfo troke;
  ImagesInfo image;
  bool isLock;
  String brushId;
  String brushName;
  String brushType;
  List<double> scale;

  ScrawlFile(
      {this.thumb,
      this.lines,
      this.troke,
      this.image,
      this.isLock,
      this.brushName,
      this.brushType,
      this.scale});

  ScrawlFile.fromJson(Map<String, dynamic> json) {
    thumb = json['thumb'];
    lines = json['lines'] != null ? LineInfo.fromJson(json['lines']) : null;
    troke = json['troke'] != null ? StrokeInfo.fromJson(json['troke']) : null;
    image = json['image'] != null ? ImagesInfo.fromJson(json['image']) : null;
    isLock = json['isLock'];
    brushName = json['brushName'];
    brushType = json['brushType'];
    if (json['scale'] != null) {
      List list = json['scale'];
      scale = list.map((model) {
        if (model is double) {
          return model;
        } else if (model is int) {
          return model * 1.0;
        } else {
          return double.parse(model);
        }
      }).toList();
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['thumb'] = this.thumb;
    if (this.lines != null) {
      data['lines'] = this.lines.toJson();
    }
    if (this.troke != null) {
      data['troke'] = this.troke.toJson();
    }
    if (this.image != null) {
      data['image'] = this.image.toJson();
    }
    data['isLock'] = this.isLock;
    data['brushName'] = this.brushName;
    data['brushType'] = this.brushType;
    data['scale'] = this.scale;
    return data;
  }
}

class LineInfo {
  int width;
  String color;
  int dashedSpacing;
  int dashedWidth;
  int shadowRadius;
  String shadowColor;
  String bgImageName;

  LineInfo(
      {this.width,
      this.color,
      this.dashedSpacing,
      this.dashedWidth,
      this.shadowRadius,
      this.shadowColor,
      this.bgImageName});

  LineInfo.fromJson(Map<String, dynamic> json) {
    width = json['width'];
    color = json['color'];
    dashedSpacing = json['dashedSpacing'];
    dashedWidth = json['dashedWidth'];
    shadowRadius = json['shadowRadius'];
    shadowColor = json['shadowColor'];
    bgImageName = json['bgImageName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['width'] = this.width;
    data['color'] = this.color;
    data['dashedSpacing'] = this.dashedSpacing;
    data['dashedWidth'] = this.dashedWidth;
    data['shadowRadius'] = this.shadowRadius;
    data['shadowColor'] = this.shadowColor;
    data['bgImageName'] = this.bgImageName;
    return data;
  }
}

class StrokeInfo {
  int width;
  String color;

  StrokeInfo({this.width, this.color});

  StrokeInfo.fromJson(Map<String, dynamic> json) {
    width = json['width'];
    color = json['color'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['width'] = this.width;
    data['color'] = this.color;
    return data;
  }
}

class ImagesInfo {
  int width;
  List<String> name;
  int spacing;
  bool isRotation;

  ImagesInfo({this.width, this.name, this.spacing, this.isRotation});

  ImagesInfo.fromJson(Map<String, dynamic> json) {
    width = json['width'];
    name = json['name'].cast<String>();
    spacing = json['spacing'];
    isRotation = json['isRotation'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['width'] = this.width;
    data['name'] = this.name;
    data['spacing'] = this.spacing;
    data['isRotation'] = this.isRotation;
    return data;
  }
}
